@extends('admin.master')

@section('style')
<link rel="stylesheet" href="{{ url('js/prettyphoto/css/prettyPhoto.css') }}">
@endsection

@section('top')
<div class="top-breadcrumb pull-left">{!! Breadcrumbs::render() !!}</div>
@endsection

@section('content')
	<div class="customer-show">
		<div class="customer-info mb10">
			<h3 class="customer-order-title">{{ $customer->name }}</h3>
		</div>
		<div class="customer-order">
			<table class="table table-bordered">
				<thead>
					<th width="65" class="text-center">订单ID</th>
					<th>客户名称</th>
					<th>提单时间</th>
					<th>到期时间</th>
					<th class="text-center">年限</th>
					<th>订单类型</th>
					<th>标签</th>
					<th>业务员</th>
					<th>域名</th>
					<th>签单金额</th>
					<th>到账</th>
					<th>尾款</th>
					<th>进度</th>
					<th class="text-right">操作</th>
				</thead>
		<tbody>
			@foreach ($orders as $value)
				<tr>
					<td class="text-center">{{ $value->id }}</td>
					<td>{{ $value->customer->name }}</td>
					<td>{{ $value->created_at->format('Y-m-d') }}</td>
					<td><span class="text-danger">{{ $value->expired_at->format('Y-m-d') }}</span></td>
					<td class="text-center">{{ $value->year }}</td>
					<td><span class="label label-info">{{config('system.product')[$value->type][$value->product] }}</span></td>
					<td><span class="text-warning">{{ $value->tag }}</span></td>
					<td>{{ $value->saler->name or '' }}</td>
					<td><a href="http://{{ $value->domain }}" target="_blank">{{ $value->domain }}</a></td>
					<td>{{ (int)$value->amount }}</td>
					<td>{{ $value->amount - $value->tail_amount }}</td>
					<td>{{ (int)$value->tail_amount }}</td>
					<td><span class="label label-info">{{ config('system.order_status')[$value->status] }}</span></td>	
					<td class="text-right">
						<div class="toolbar">
							<a href="{{ route('admin.order.show', [$value->id, 'u'=>1]) }}" class="btn-link">查看</a>
						</div>
					</td>
				</tr>
			@endforeach
		</tbody>
			</table>
		</div>
		<div class="partition"><span>续费</span></div>
		<table class="table table-bordered">
		    <thead>
		        <tr>
		        	<th width="65" class="text-center">订单ID</th>
		            <th>续费时间</th>
		            <th>年限</th>
		            <th>业务员</th>
		            <th>续费金额</th>
		            <th>备注</th>
 					<th>合同</th>
		        </tr>
		    </thead>
		    <tbody>
		    @if (!$renews->isEmpty())
		        @foreach($renews as $renew)
		        <tr>
		        	<td class="text-center text-size-14">{{ $renew->order->id }}</td>
		            <td>{{ $renew->created_at->format('Y-m-d') }}</td>
		            <td>{{ $renew->year }}</td>
		            <td>{{ $renew->saler->name }}</td>
		            <td>{{ $renew->amount }}</td>
		            <td>{{ $renew->remark }}</td>
		            <td>
		            	@if ($renew->contract)
							<table class="table table-bordered mb0 mt0">
							    <thead>
							        <tr>
							            <th>合同号</th>
							            <th>合同图片</th>
							            <th>发票类型</th>
							            <th>发票回执</th>
							            <th>发票状态</th>
							            <th>回执状态</th>
							        </tr>
							    </thead>
							    <tbody>
							        <tr>
							            <td><code>{{ $renew->contract->contract_no or '无' }}</code></td>
							            <td>
							            @if ($renew->contract->contract && $renew->contract->contract && is_array($renew->contract->contract))
							                <ul class="contract-imgs">
							                    @foreach($renew->contract->contract as $contract)
							                    <li>
							                        <a href="{{ url($contract) }}" class="thumbnail" rel="prettyPhoto[contracts-renew]">
							                            <img src="{{ thumbFull($contract, 80) }}">
							                        </a>
							                    </li>
							                    @endforeach
							                </ul>
							            @endif
							            </td>
							            <td>{{ config('system.invoice_type')[$renew->contract->invoice_type] }}</td>
							            <td>
							            @if ($renew->contract->invoice_receipt && is_array($renew->contract->invoice_receipt))
							                <ul class="contract-imgs">
							                    @foreach($renew->contract->invoice_receipt as $receipt)
							                    <li>
							                        <a href="{{ url($receipt) }}" class="thumbnail" rel="prettyPhoto[receipts-renew]">
							                            <img src="{{ thumbFull($receipt, 80) }}">
							                        </a>
							                    </li>
							                    @endforeach
							                </ul>
							            @endif 
							            </td>
							            <td>
							                @if($renew->contract->invoice_status == 1)
							                    <span class="label label-success">发票已开</span>
							                @endif
							            </td>
							            <td>
							                @if($renew->contract->invoice_receipt_status == 1)
							                    <span class="label label-success">回执已收</span>
							                @endif
							            </td>
							        </tr>
							    </tbody>
							</table>	
		            	@else
		            		<span class="text-warning">暂无合同</span>
		            	@endif
		            </td>
		        </tr>
		        @endforeach
		    @endif
		    </tbody>
		</table>
		@if ($renews->isEmpty())  
		<div class="simple-none-data text-center none-data-condensed">
			<i class="fa fa-exclamation-circle text-size-20 text-muted" style="vertical-align: middle"></i> 
			<span class="text-size-14 inline-block ml5">暂无续费记录</span>
		</div>
		@endif
	</div>
@endsection

@section('foot')
<script src="{{ url('js/prettyphoto/jquery.prettyPhoto.js') }}"></script>
<script>
$(function() {
    $("a[rel^='prettyPhoto']").prettyPhoto({social_tools: ''});
});
</script>
@endsection
